var modalConfirmOptions = {divName: 'confirm', title: 'CONFIRM', yes:'YES', no: 'NO'};

function modalConfirm(message, yescallback, nocallback){
	
	var confirmDiv  = '<div id="'+modalConfirmOptions.divName+'">';
	    confirmDiv += '    <div class="header"><span>'+modalConfirmOptions.title+'</span></div>';
	    confirmDiv += '    <div class="message"></div>';
	    confirmDiv += '    <div class="buttons">';
	    confirmDiv += '        <hr/>';
	    if (nocallback !== null) confirmDiv += '        <div class="no simplemodal-close">'+modalConfirmOptions.no+'</div>';
	    confirmDiv += '        <div class="yes">'+modalConfirmOptions.yes+'</div>';
	    confirmDiv += '    </div>';
	    confirmDiv += '</div>';
	
	var confirm = $('#'+modalConfirmOptions.divName);
	
	if(confirm.length != 0) {
		confirm.remove();
	}
    $(confirmDiv).appendTo($('body'));
    confirm = $('#'+modalConfirmOptions.divName);
    
	confirm.modal({
		closeHTML: "<a href='#' title='Close' class='modal-close'>x</a>",
		position: ["30%",],
		overlayId: 'confirm-overlay',
		containerId: 'confirm-container', 
		onShow: function (dialog) {
			var modal = this;

			$('.message', dialog.data[0]).append(message);

			// if the user clicks "yes"
			$('.yes', dialog.data[0]).click(function () {
				// close the dialog
				$.modal.close(); // or $.modal.close();
				
				// call the callback
				if ($.isFunction(yescallback)) {
					yescallback.apply();
				}
			});
			
			// if the user clicks "yes"
			$('.no', dialog.data[0]).click(function () {
				// close the dialog
				$.modal.close(); // or $.modal.close();
				
				// call the callback
				if ($.isFunction(nocallback)) {
					nocallback.apply();
				}
			});
		}
	});
}